Merge "Normalize `input[type="search"]`"
[lhc/web/wiklou.git] / maintenance / rebuildLocalisationCache.php
index f89877e..82b362b 100644 (file)
@@ -29,6 +29,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -39,7 +41,7 @@ require_once __DIR__ . '/Maintenance.php';
 class RebuildLocalisationCache extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Rebuild the localisation cache";
+               $this->addDescription( 'Rebuild the localisation cache' );
                $this->addOption( 'force', 'Rebuild all files, even ones not out of date' );
                $this->addOption( 'threads', 'Fork more than one thread', false, true );
                $this->addOption( 'outdir', 'Override the output directory (normally $wgCacheDirectory)',
@@ -104,16 +106,16 @@ class RebuildLocalisationCache extends Maintenance {
                $numRebuilt = 0;
                $total = count( $codes );
                $chunks = array_chunk( $codes, ceil( count( $codes ) / $threads ) );
-               $pids = array();
+               $pids = [];
                $parentStatus = 0;
                foreach ( $chunks as $codes ) {
                        // Do not fork for only one thread
                        $pid = ( $threads > 1 ) ? pcntl_fork() : -1;
 
                        if ( $pid === 0 ) {
-                               // Child, reseed because there is no bug in PHP:
-                               // http://bugs.php.net/bug.php?id=42465
-                               mt_srand( getmypid() );
+                               // Reset services, so we don't re-use connections.
+                               MediaWikiServices::resetChildProcessServices();
+
                                $this->doRebuild( $codes, $lc, $force );
                                exit( 0 );
                        } elseif ( $pid === -1 ) {